package edu.hdu.hangzhe.bytecode.domain;

import org.objectweb.asm.Label;

/**
 * ABI: Abstract Bytecode Instrument
 */
public class ABI {
    private Label label;
    // INST
    public String inst;
    // Value
    public String value;
    // Slot
    private String slot;

    private int line;

    private boolean isPattern = false;

    public ABI(String realInst, String value) {
        this.label = null;
        this.inst = realInst;
        this.value = value;
    }

    public void setInst(String inst) {
        this.inst = inst;
    }

    public void setLabel(Label label) {
        this.label = label;
    }

    public Label getLabel() {
        return label;
    }

    @Override
    public String toString() {
        return "ABI{" +
                "inst='" + inst + '\'' +
                (!isPattern ? ", value='" + value + '\'' : ", slot='" + slot + '\'') +
                "}\n";
    }

    @Override
    public boolean equals(Object obj) {
        return this.toString().equals(obj.toString());
    }

    public int getLine() {
        return line;
    }

    public void setLine(int line) {
        this.line = line;
    }

    public String getSlot() {
        return slot;
    }

    public void setSlot(String slot) {
        this.slot = slot;
        isPattern = true;
    }
}
